package com.midea.ai.air.ui.more.fragment;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.midea.ai.air.R;
import com.midea.ai.air.common.BaseFragment;
import com.midea.ai.air.common.ConsVal;
import com.midea.ai.air.ui.home.ActivityDetails;
import com.midea.ai.air.ui.more.adapter.FamilyMemberAdapter;
import com.midea.ai.air.ui.more.data.FamilyMember;
import com.midea.ai.air.utils.JumpUtils;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by ouyangdi on 2016/4/16.
 * 更多->我的家庭Fragment
 */
public class MoreFamilyFragment extends BaseFragment {
    private RelativeLayout mSelectFamily;
    private TextView mFamilyName;
    private ListView mListMember;
    private List<FamilyMember> mFamilyMembers;
    private FamilyMemberAdapter mMemberAdapter;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_more_family, container, false);
        initData();
        initView(view);
        return view;
    }

    private void initData() {
        mFamilyMembers = new ArrayList<>();
        mFamilyMembers.add(new FamilyMember(R.drawable.air_more_family_photo1,"zhangsan"));
        mFamilyMembers.add(new FamilyMember(R.drawable.air_more_family_photo2,"lisi"));
        mMemberAdapter = new FamilyMemberAdapter(getActivity(), 0, mFamilyMembers);
    }

    private void initView(View view) {
        mSelectFamily = (RelativeLayout) view.findViewById(R.id.layout_select_family);
        mSelectFamily.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                JumpUtils.toPage(getActivity(), getString(R.string.air_more_family_select), getString(R.string.air_more_family_my_family), ConsVal.ACTIVITY_TAG_MORE_FAMILY_SELECT_FAMILY, ActivityDetails.class);
            }
        });
        mFamilyName = (TextView) view.findViewById(R.id.tv_family_name);
        mFamilyName.setText("展厅");

        mListMember = (ListView) view.findViewById(R.id.list_family_member);
        mListMember.setAdapter(mMemberAdapter);
    }
}
